package vista;
import java.awt.BorderLayout;
import java.awt.HeadlessException;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;

import controlador.interfaces.IControladorPrincipal;

import vista.interfaces.IVistaPrincipal;


/**
* This code was edited or generated using CloudGarden's Jigloo
* SWT/Swing GUI Builder, which is free for non-commercial
* use. If Jigloo is being used commercially (ie, by a corporation,
* company or business for any purpose whatever) then you
* should purchase a license for each developer using Jigloo.
* Please visit www.cloudgarden.com for details.
* Use of Jigloo implies acceptance of these licensing terms.
* A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED FOR
* THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED
* LEGALLY FOR ANY CORPORATE OR COMMERCIAL PURPOSE.
*/
public class VistaPrincipal extends JFrame implements IVistaPrincipal {
	private JPanel panel;
	private JButton btnAgregarUsuario;
	private IControladorPrincipal controladorPrincipal;

	public VistaPrincipal() throws HeadlessException {
		super();
		initGUI();
		setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
		this.addWindowListener(new WindowListener() {
			
			@Override
			public void windowOpened(WindowEvent e) {
				// TODO Auto-generated method stub
				
			}
			
			@Override
			public void windowIconified(WindowEvent e) {
				// TODO Auto-generated method stub
				
			}
			
			@Override
			public void windowDeiconified(WindowEvent e) {
				// TODO Auto-generated method stub
				
			}
			
			@Override
			public void windowDeactivated(WindowEvent e) {
				// TODO Auto-generated method stub
				
			}
			
			@Override
			public void windowClosing(WindowEvent e) {
				controladorPrincipal.close();
			}
			
			@Override
			public void windowClosed(WindowEvent e) {
				
			}
			
			@Override
			public void windowActivated(WindowEvent e) {
				// TODO Auto-generated method stub
				
			}
		});
	}

	private void initGUI() {
		try {
			{
				this.setBounds(0, 0, 261, 191);
				{
					panel = new JPanel();
					getContentPane().add(panel, BorderLayout.CENTER);
					panel.setLayout(null);
					{
						btnAgregarUsuario = new JButton();
						panel.add(btnAgregarUsuario);
						btnAgregarUsuario.setText("Agregar Usuario");
						btnAgregarUsuario.setBounds(62, 61, 99, 24);
						btnAgregarUsuario.addActionListener(new ActionListener() {
							public void actionPerformed(ActionEvent evt) {
								btnAgregarUsuarioActionPerformed(evt);
							}
						});
					}
				}
			}
		} catch(Exception e) {
			e.printStackTrace();
		}
	}

	@Override
	public void setControlador(IControladorPrincipal controladorPrincipal) {
		this.controladorPrincipal = controladorPrincipal;
	}
	
	public void mostrar() {
		this.setVisible(true);
	}
	
	private void btnAgregarUsuarioActionPerformed(ActionEvent evt) {
		this.controladorPrincipal.startAgregarUsuario();
	}
}
